package com.dj.uphome.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.dj.common.web.controller.CoreCrudRestController;



/***
 * 
 * @author ML
 *
 */
@Controller
@RequestMapping(value = "/images")
public class ImagesController extends CoreCrudRestController {
	/*@Autowired
	private OssUtil ossUtil;
	*//**
	 * 上传图片
	 *//*
	@RequestMapping(value = "/upload/base64", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
	public ResponseEntity<ResponsePack<PageData>> upload(@RequestParam String data,String fileName) throws Exception {
		try{
			if(null!=data&&data.indexOf("/")>0&&data.indexOf(",")>0){
				data = data.substring(data.indexOf(",")+1);
			}	
			BASE64Decoder decoder = new BASE64Decoder();
			byte[] d = decoder.decodeBuffer(data);
			if(null == d){
				throw new InvalidRequestException("找不到图片资源", 105);
			}			
			if(StringUtils.isEmpty(fileName)){
				fileName = UuidUtil.get32UUID()+".png";
			}
			String s = ossUtil.putObjectForImage(fileName, d);
			if(StringUtils.isEmpty(s)){
				throw new InvalidRequestException("上传图片失败", 105);
			}
			PageData pd = new PageData();
			pd.put("url", s);
			return new ResponseEntity<>(new ResponsePack<>(pd), HttpStatus.OK);
		}catch(Exception e){
			throw new InvalidRequestException("图片上传失败", 105);
		}
	}*/
}
